package com.gang.music.system.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.gang.music.system.entity.RoleMenu;
import com.gang.music.system.mapper.RoleMenuMapper;
import com.gang.music.system.service.RoleMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author gang
 * @since 2017-10-29
 */
@Service
public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> implements RoleMenuService {

	@Autowired
	private RoleMenuMapper roleMenuMapper;
	
	@Override
	public List<Integer> findMenuIdsByRoleId(Integer roleId) {
		
		return roleMenuMapper.selectMenuIdsByRoleId(roleId);
	}

	@Override
	public void insert(Integer roleId, List<Integer> menuIdList) {
		
		roleMenuMapper.batchInsert(roleId, menuIdList);
	}

	@Override
	public void update(Integer roleId, List<Integer> menuIdList) {
		
		roleMenuMapper.deleteByRoleId(roleId);
		roleMenuMapper.batchInsert(roleId, menuIdList);
	}
}
